mainModule.controller('resCtrl', ['$scope','$rootScope','$stateParams','$window', 'api',
                                   function($scope,$rootScope,$stateParams,$window,api ) {
       
       $scope.choose=false;

       if($stateParams.id) $scope.showBack=true;

       $scope.tree=function(d){
         api.res.tree(function(data){
       	    $scope.list=data;
       	    $scope.$broadcast('list', data);  
         },d);                            	
       }
       $scope.tree({type:2,id:$stateParams.id});

       $scope.go=function(id){
       	    $window.location.href="#/res?id="+id;
       }
       $scope.back=function(){ 
       	 $window.history.back();
       }

}]);

mainModule.controller('resModalCtrl', ['$scope','$rootScope','$stateParams', 'api','D',
                                   function($scope,$rootScope,$stateParams,api ,D) {
    $scope.icons = D.icons;
    $scope.f={};

    $scope.$on('list',function(event,data){
    	$scope.list =data;
    });

    $scope.f.submit=function(){ 
     
    }

}]);